package com.config;


import com.vo.ResponseBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 控制层异常切面，会和控制层代码组合，拦截异常进行处理
 */
@Configuration
@ControllerAdvice
public class ExceptionHandlerConfig {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseBean handler(Exception e)
    {
        return new ResponseBean(500,0,e.getMessage());
    }
}
